package cz.idsv.web.mvc.model.service;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Service;

import cz.idsv.web.mvc.model.dao.ProductDao;
import cz.idsv.web.mvc.model.entity.ProductEntity;


@Service("ProductService")
public class ProductServiceImpl implements ProductService {

	@Autowired()
	private ProductDao productDao;
	
	
	public Collection<ProductEntity> findProduct() throws DataAccessException{
		return productDao.findProduct();
	}

	public void save( ProductEntity  productEntity) {
		 productDao.save( productEntity);
	}

	@Secured ({"ROLE_ADMIN"})
	public void delete( ProductEntity  productEntity) {
		 productDao.delete( productEntity);
	}

	public  ProductEntity findProductById(Integer id)
			throws DataAccessException {
		return  productDao.findProductById(id);
	}
}
